﻿<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Checkout.aspx.vb" Inherits="CheckoutPage" %>
<%@ Register src="Login.ascx" tagname="Login" tagprefix="uc1" %>
<%@ Register src="CustomerInfo.ascx" tagname="CustomerInfo" tagprefix="uc2" %>
<%@ Register src="CreditCard.ascx" tagname="CreditCard" tagprefix="uc3" %>
<%@ Register src="CartSummary.ascx" tagname="CartSummary" tagprefix="uc4" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <script language="javascript" type="text/javascript">
        function clearcart()
        {
            document.getElementById("lblCartSummary").innerHTML = 0;
        }
        function Popup()
        {

            var sOpenAttributes = 'status=no,toolbar=yes,menubar=no,location=no,resizable=yes,height=500,width=800';
            var orderid = document.getElementById("lblConfirmation").innerHTML;
            window.open("Receipt.aspx?o=" + orderid.toString(), null, sOpenAttributes);
        }
    </script>
    <asp:UpdatePanel ID="upnlCheckout" runat="server">
    <ContentTemplate>
    <center>
    <asp:Label ID="lblMyCustomerID" runat="server" Visible="false" />
    <center>
        <asp:Panel runat="server" Visible="false" ID="pnlConfirm">
            <span>Thank you, your order has been placed.</span><br />
            <b style="font-size:14pt;">Order #<asp:Label ClientIDMode="Static" ID="lblConfirmation" runat="server" /></b><br /><br />
            <asp:LinkButton ID="btnReciept" OnClientClick="Popup()" Text="Print Receipt" runat="server" />
        </asp:Panel>
    </center>
        <asp:Wizard NavigationButtonStyle-CssClass="btn"  CssClass="wizCheckout" 
            DisplaySideBar="False" ID="wizCheckout" 
            runat="server">
            <FinishNavigationTemplate>
                <center>
                <asp:Button ID="FinishPreviousButton" runat="server" CausesValidation="False" 
                    CommandName="MovePrevious" Text="Previous" />
                <asp:Button ID="FinishButton" OnClientClick="clearcart()" runat="server" CommandName="MoveComplete" 
                    Text="Complete Order" />
                </center>
            </FinishNavigationTemplate>
            <NavigationButtonStyle CssClass="btn" />
            <StartNavigationTemplate>
                <center>
                <asp:Button ID="StartNextButton" runat="server" CausesValidation="true" CommandName="MoveNext" 
                    Text="Next" />
                </center>
            </StartNavigationTemplate>
            <StepNavigationTemplate>
                <center>
                <asp:Button ID="StepPreviousButton" runat="server" CausesValidation="False" 
                    CommandName="MovePrevious" Text="Previous" />
                <asp:Button ID="StepNextButton" runat="server" CausesValidation="true" CommandName="MoveNext" 
                    Text="Next" />
                </center>
            </StepNavigationTemplate>
            <WizardSteps>
                <asp:WizardStep ID="WizardStep1" StepType="Step" runat="server" title="Step 1">
                    <asp:UpdatePanel ID="upnlCheckout1" runat="server" UpdateMode="Always" >
                        <ContentTemplate>
                            <h1>Customer Information</h1>
                            <center>
                            <asp:RadioButtonList AutoPostBack="True" CssClass="radio" ID="rdlChoice" runat="server" RepeatDirection="Horizontal">
                                <asp:ListItem Value="0" Text="Existing Customer" />
                                <asp:ListItem Value="1" Text="New Customer" />
                            </asp:RadioButtonList>
                            <uc1:Login Visible="false" ID="Login1" runat="server" />
                            <uc2:CustomerInfo Visible="false" Redirect="false" ShowButton="false" Mode="Insert" ID="CustomerInfo1" runat="server" />
                            </center>
                    </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="rdlChoice" EventName="SelectedIndexChanged" />
                        </Triggers>
                    </asp:UpdatePanel>
                </asp:WizardStep>
                <asp:WizardStep ID="WizardStep2" StepType="Step" runat="server" title="Step 2">
                    <asp:UpdatePanel ID="upnlCheckout2" runat="server">
                        <ContentTemplate>
                            <h1>Billing Information</h1>
                            <center> 
                            <asp:RadioButtonList AutoPostBack="True" CssClass="radio" ID="rdlChoice2" runat="server" RepeatDirection="Horizontal">
                                <asp:ListItem Value="0" Text="New Card" />
                                <asp:ListItem Value="1" Text="Existing Card" />
                            </asp:RadioButtonList>
                            <asp:DropDownList Visible="false" ID="ddlCardList" runat="server" DataSourceID="adsCardList" 
                                DataTextField="CardInfo" DataValueField="CardID">
                            </asp:DropDownList><br />
                            <asp:AccessDataSource ID="adsCardList" runat="server" 
                                DataFile="~/App_Data/GotPink.accdb" 
                                SelectCommand="SELECT [CardID], CardType +'|'+ [CardNumber] as CardInfo  FROM [CustomerCards] WHERE [IsDeleted] = False AND [CustomerID] = ? ">
                                <SelectParameters>
                                    <asp:ControlParameter ControlID="lblMyCustomerID" Name="CustomerID" 
                                        PropertyName="Text" Type="Int32" />
                                </SelectParameters>
                            </asp:AccessDataSource>
                            <br />
                            <uc3:CreditCard Mode="Insert" ShowButton="false" ID="CreditCard1" runat="server" />
                            </center>   
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="rdlChoice2" EventName="SelectedIndexChanged" />
                        </Triggers>
                    </asp:UpdatePanel>
                </asp:WizardStep>
                <asp:WizardStep ID="WizardStep3" StepType="Finish" runat="server" title="Step 3">
                    <asp:UpdatePanel runat="server" ID="upnlCheckout3" >
                        <ContentTemplate>
                        <h1>Complete Order</h1>
                            <uc4:CartSummary CartString="MyCart" ReadOnlyMode="true" ID="CartSummary1" runat="server" /><br />
                            <asp:UpdateProgress ID="UpdateProgress1" runat="server">
                                <ProgressTemplate>
                                <center>
                                    Processing your request...<br />
                                    <img alt="Processing" src="Images/processing4.gif" />
                                </center>
                                </ProgressTemplate>
                            </asp:UpdateProgress>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </asp:WizardStep>
            </WizardSteps>
        </asp:Wizard>
        </center>
        <br />
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="wizCheckout" EventName="NextButtonClick" />
        <asp:AsyncPostBackTrigger ControlID="wizCheckout" EventName="FinishButtonClick" />
    </Triggers>
</asp:UpdatePanel>
</asp:Content>

